package com.example.demo.practice;

import java.util.concurrent.TimeUnit;

/**
 * @author liweizhi
 * @date 2020/4/28
 */
public class WaitNotify {
    public static void main(String[] args) {
        Object obj = new Object();
        new Thread(() -> {
            try {
                TimeUnit.SECONDS.sleep(3);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synchronized (obj) {
                obj.notifyAll();
            }
        }).start();
        System.out.println("start");
        synchronized (obj) {
            try {
                obj.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("end");

    }
}
